export const getFormData = (item, status) => {
  let data = {};
  if (item && item.length) {
    item.forEach(e => {
      if (Number(status) == 1) {
        e.disabled = true;
      }
      if (e.keyId) {
        if (e.type == "FormListImageFile") {
          let fileVal = JSON.parse(e.val);
          if (!fileVal) {
            return;
          }
          data[e.keyId] = fileVal;
        } else {
          data[e.keyId] = JSON.parse(e.val)[0];
        }
      } else {
        data[e.keyId] = e.val;
      }
    });
  } else {
    data = {};
  }
  return data;
};

export const toForm = (from, disabled) => {
  from.forEach(e => {
    e.field = e.keyId;
    e.props = {};
    e.props.disabled = disabled;
  });
  return from;
};
